#include "AI.h"

extern list<WordInfo> word_list;
extern list<WordInfo>::iterator word_it;

extern list<AdditionalInfo> additional_list;
extern list<AdditionalInfo>::iterator additional_it;

bool PhoneNumTag(char* word)
{
	int n = 0;
	int hyphenCount = 0;
	int nowNum = 0;
	bool typeFlag = false; // if xxxx-xxxx, true

	if(strlen(word) < 7)
	{
		return false;
	}

	while(word[n] != NULL)
	{
		if(word[n] >= '0' && word[n] <= '9')
		{
			nowNum++;
		}

		else if(word[n] == '-')
		{
			hyphenCount++;

			if(hyphenCount == 1)
			{
				if(nowNum == 4)
				{
					typeFlag = true;
				}

				else if(nowNum < 2 || nowNum > 4)
				{
					return false;
				}
			}

			else if(hyphenCount == 2)
			{
				if(typeFlag == true)
				{
					return false;
				}

				else if(nowNum < 3 || nowNum > 4)
				{
					return false;
				}
			}

			else if(hyphenCount == 3)
			{
				return false;
			}

			nowNum = 0;
		}

		else
		{
			return false;
		}

		n++;
	}

	if(hyphenCount == 0)
	{
		if(strlen(word) > 11)
		{
			return false;
		}

		else
		{
			return true;
		}
	}

	else if(nowNum != 4)
	{
		return false;
	}

	else
	{
		return true;
	}
}